package cn.school.service;

import cn.school.dao.SubjectDao;
import cn.school.entity.Subject;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.session.SqlSession;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
//import util.LogUtil;
//import util.MybatisUtil;

import java.util.List;

@Service
public class SubjectService {
    @Autowired
    private  SubjectDao mapper;
    public int add(Subject o){
        return mapper.add(o);

    }
    public Subject get(long id){
          return mapper.get(id);

    }

    public List<Subject> search( String subname,   int pageNo, int pageSize){
        if(pageNo<1)
            pageNo=1;
          return mapper.search(subname,pageNo,pageSize);

    }
    //返回总页数
    public int searchTotal(String subname,int pageSize){
           int r= mapper.searchTotal(subname);
            return r/pageSize+(r%pageSize==0?0:1);

    }
    public int del(long id){
         return mapper.del(id);

    }
}
